/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agh.air.bpel2bpmn.comparator.impl;

import org.agh.air.bpel2bpmn.comparator.AbstractComparator;
import org.agh.air.bpel2bpmn.exception.PatternNotFoundException;
import org.w3c.dom.Node;

/**
 *
 * @author paletz
 */
public class CaseComparator extends AbstractComparator{

    private final String CONDITION = "condition";
    
   /*   <case condition="3">
            <invoke name="Task-13069" partnerLink="" portType="" operation="" inputVariable="" outputVariable=""/>
        </case>
   */

    @Override
    public String compare(Node node) throws PatternNotFoundException {
        if(node.getNodeName().equals(CASE)) {
            if(node.hasChildNodes()){
                if(getFirstChild(node).getNodeName().equals(INVOKE))
                    return "case"+ LTMP + getAttributeByName(node, CONDITION) + "."+ getNameAttribute(getFirstChild(node)) + RTMP;
                else
                    return "case"+ LTMP + getAttributeByName(node, CONDITION) + "."+ getFirstChild(node).getNodeName() + RTMP;
            }
        }
            
        
        throw new PatternNotFoundException();
    }
    
}
